<template>
  <div class="box">
    <div class="content">
      <div class="student">
        <div class="student-avatar">
          <!-- https://img1.baidu.com/it/u=2716398045,2043787292&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=800 -->
          <img v-if="tableData.studentAvatar" :src="tableData.studentAvatar" alt="" />
          <img v-else src="@/assets/images/accommodation/popup_img_peo.png" alt="" />
        </div>
        <ul class="student-info">
          <li>
            <span class="title">姓名：</span>
            <span class="text">{{ tableData.studentName }}</span>
          </li>
          <li>
            <span class="title">班级：</span>
            <span class="text">{{ tableData.className }}</span>
          </li>
          <li>
            <span class="title">房间名：</span>
            <span class="text">{{ tableData.roomName }}</span>
          </li>
          <li>
            <span class="title">检查人：</span>
            <span class="text">{{ tableData.markUserName }}</span>
          </li>
          <li>
            <span class="title">检查人电话：</span>
            <span v-if="tableData.markUserPhone" class="text">{{ tableData.markUserPhone }}</span>
            <span v-else class="text">--</span>
          </li>
          <li>
            <span class="title">得/扣分：</span>
            <span :class="['text', 'red']">{{ tableData.markScoreSum }}</span>
          </li>
          <li>
            <span class="title">宿舍：</span>
            <span class="text">{{ tableData.dormitoryName }}</span>
          </li>
          <li>
            <span class="title">检查类型：</span>
            <span class="text">{{ tableData.superiorName }}</span>
          </li>
          <li>
            <span class="title">检查时间：</span>
            <span class="text">{{ tableData.examineTime }}</span>
          </li>
          <li>
            <span class="title">打分时间：</span>
            <span class="text">{{ tableData.markTime }}</span>
          </li>
        </ul>
      </div>
      <div class="flex">
        <div style="width: 100%">
          <div v-for="(item, index) in tableData.markItemDetail" :key="index" class="deduct-points">
            <div class="small-title">{{ item.itemName }}</div>
            <div style="display: flex">
              <div class="deduct-points-content" style="width: 100%">
                <div class="content-details">
                  <ul>
                    <li v-for="(list, i) in item.itemList" :key="i">
                      <span class="points"
                        >{{ list.markItemName }}
                        <span v-if="tableData.examineType * 1 !== 1">：</span>
                      </span>
                      <span v-if="tableData.examineType * 1 !== 1" class="deduct">{{
                        list.markScore === 0
                          ? 0
                          : list.markScore > 0
                          ? '+' + list.markScore
                          : list.markScore
                      }}</span>
                    </li>
                  </ul>
                </div>
              </div>
            </div>
          </div>
          <!-- 图片-->
          <div v-if="tableData.imgUrlsList" class="deduct-points">
            <div class="small-title">项目扣分图</div>
            <div class="deduct-points-content">
              <div class="content-img-box">
                <div v-for="item in tableData.imgUrlsList" :key="item" class="content-img">
                  <img :src="item" alt="" />
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';
import { getStudentExamineDetails } from '@/api/assessment/dormitoryPersonal';
import { message } from 'ant-design-vue';
const router = useRouter();
onMounted(() => {
  let obj = {
    studentUserId: router.currentRoute.value.query.studentUserId.toString(),
    examineId: router.currentRoute.value.query.examineId.toString(),
    superiorId: router.currentRoute.value.query.superiorId.toString()
  };
  let bodySty = document.getElementById('myApp');
  bodySty.setAttribute('class', 'bodyStyle');
  getTabsList(obj);
});
// 信息
const tableData = ref([]);
// 获取信息
function getTabsList(obj) {
  getStudentExamineDetails(obj).then(res => {
    if (res.data.code === 200) {
      tableData.value = res.data.data;
      console.log('tableData', tableData.value);
      console.log(tableData.value);
      if (tableData.value.imgUrls !== '') {
        tableData.value.imgUrlsList = [];
        tableData.value.imgUrls.split(',').forEach(i => {
          tableData.value.imgUrlsList.push(i);
        });
      }
    } else {
      message.error(res.data.msg);
      setTimeout(() => {
        router.go(-1);
      }, 300);
    }
  });
}
</script>

<style lang="less" scoped>
.box {
  background: #f2f2f2;
  // padding: 50px 120px 24px;
  min-height: 100vh;
  .content {
    background: #ffffff;
    border-radius: 4px;
    padding: 24px;
    .student {
      border: 1px solid #e4b778;
      border-radius: 4px;
      padding: 24px;
      width: 100%;
      display: flex;
      align-items: center;
      margin-bottom: 24px;
      .student-avatar {
        width: 80px;
        height: 106px;
        border-radius: 4px;
        overflow: hidden;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .student-info {
        flex: 1;
        display: flex;
        flex-wrap: wrap;
        padding: 0 24px;
        margin-bottom: 0;
        li {
          width: 20%;
          padding: 12px 0;
          font-size: 14px;
          .title {
            color: #999999;
            display: inline-block;
            width: 40%;
            text-align: end;
          }
          .text {
            color: #222222;
          }
          .red {
            color: #ff0000;
          }
        }
      }
    }
    .deduct-points {
      margin-bottom: 32px;
      &-content {
        padding: 14px 16px;
        background: #f8f8f8;
        border-radius: 4px;
        margin-top: 20px;
        display: flex;
        align-items: center;
      }
      .content-details {
        width: 100%;
        ul {
          // display: flex;
          // align-items: center;
          // flex-wrap: wrap;
          margin-bottom: 0;
          line-height: 32px;
          li {
            // width: 30%;
            font-size: 14px;
            .points {
              color: #999999;
            }
            .deduct {
              color: #222222;
            }
          }
        }
      }
    }
  }
}
.content-img-box {
  width: 50%;
  flex: 1;
  display: flex;
  // align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-left: 10px;
  .content-img {
    width: 86px;
    height: 86px;
    border-radius: 4px;
    background: #f2f2f2;
    margin: 12px;
    overflow: hidden;
    img {
      width: 100%;
      height: 100%;
    }
  }
}
.small-title {
  font-size: 18px;
  font-family: Source Han Sans CN, Source Han Sans CN-Medium;
  font-weight: 500;
  color: #222222;
}
</style>
